import { configureStore, combineReducers } from "@reduxjs/toolkit";
import userReducer from "./user";
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/es/storage";

const reducer = combineReducers({
  user: userReducer //关于用户模块的reducer
});
const persistConfig = {
  key: "root",
  storage
};
const persistedReducer = persistReducer(persistConfig, reducer);

export const store = configureStore({
  reducer: persistedReducer,
  middleware: getDefaultMiddleware =>
    getDefaultMiddleware({
      serializableCheck: false
    })
});

export const persistor = persistStore(store);
